<fieldset>
    <div class="productsinstances form">
    <legend><?php echo __('Record Product Used using Barcode'); ?></legend>
        <?php echo $this->Form->create('onepi'); ?>
        <table class="inlineTable" width="30%">
            <tr>
                <td class="heading"><?php echo __('Barcode'); ?></td>
                <td class="data"><?php echo $this->Form->input('barcode', array('value' => '','label' => '')); ?></td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td><div class="newsubmit"><?php echo $this->Form->submit(__('Add Product Used', true), array('formnovalidate' => true, 'div' => false, 'class' => 'btn btn-success')); ?></div></td>
            </tr>
        </table>
        <br /><br />


    <?php echo $this->Form->create('products'); ?>
    <div class="productsinstances index">
        <table id="data" class="table" cellpadding="0" cellspacing="0">
        <tr>
                <th>Brand</th>
                <th>Range</th>
                <th>Category</th>
                <th>Description</th>
                <th>On Hand Level</th>
                <th>Quantity Used</th>
        </tr>
        <?php $a = 0;?>
        <?php if(!empty($products)){ ?>
        <?php foreach ($products as $product => $i): ?>
        <tr>
            <?php echo $this->Form->hidden($a, array('value' => $i['Product']['id'])); ?>
            <td><?php   echo $i['Brands']['name'];?></td>
            <td><?php   echo $i['Ranges']['name'];?></td>
            <td><?php   echo $i['Categories']['name'];?></td>
            <td><?php   echo $i['Product']['description'];?></td>
            <td><?php   echo $i['Product']['onhand_level'];?> </td>
            <td><?php   echo $this->Form->input('Quantity Used.'.$a, array('value' => $qu[$a],'label' => '', 'type' => 'number', 'step' => 'any'));?></td>
        </tr>
        <?php $a++;?>
    <?php endforeach; } else {?>
        <tr>
        <td>
    <?php echo 'No products has been inserted.'; } ?>
    </td>
        </tr>
        </table>
    </div>
    <div class="newsubmit">
        <?php echo $this->Form->submit(__('Save', true), array('formnovalidate' => true, 'div' => false, 'class' => 'btn btn-success')); ?>
        <ul><li><?php echo $this->Html->link(__('Back'), array('action' => 'index')); ?></li></ul></div>
    </div>
</fieldset>
